﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Components.OpenFile
{
    public partial class OpenFile : UserControl
    {
        OpenFileDialog opf = new OpenFileDialog();
        public event EventHandler FileChange;

        public bool AddExtension
        {
            get { return opf.AddExtension; }
            set { opf.AddExtension = value; }
        }

        public string Filter
        {
            get { return opf.Filter; }
            set { opf.Filter = value; }
        }

        public new string Text
        {
            get { return this.textBox1.Text; }
            set { this.textBox1.Text = value; }
        }

        public OpenFile()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (opf.ShowDialog() == DialogResult.OK)
            {
                this.textBox1.Text = opf.FileName;
                if(FileChange!=null)
                    FileChange(this, new EventArgs());
            }
        }
    }
}
